package com.yhthu.texthandler;

import com.yhthu.splitstrategy.SplitStrategy;

import java.util.List;

public abstract class BaseHandler<T> {

    private SplitStrategy singleSplitStrategy;
    private SplitStrategy lineSplitStrategy;
    private SplitStrategy wordSplitStrategy;

    public SplitStrategy getSingleSplitStrategy() {
        return singleSplitStrategy;
    }

    public void setSingleSplitStrategy(SplitStrategy singleSplitStrategy) {
        this.singleSplitStrategy = singleSplitStrategy;
    }

    public SplitStrategy getLineSplitStrategy() {
        return lineSplitStrategy;
    }

    public void setLineSplitStrategy(SplitStrategy lineSplitStrategy) {
        this.lineSplitStrategy = lineSplitStrategy;
    }

    public SplitStrategy getWordSplitStrategy() {
        return wordSplitStrategy;
    }

    public void setWordSplitStrategy(SplitStrategy wordSplitStrategy) {
        this.wordSplitStrategy = wordSplitStrategy;
    }

    String[] executeSingleSplitStrategy(String text) {
        return singleSplitStrategy.splitText(text);
    }

    String[] executeLineSplitStrategy(String text) {
        return lineSplitStrategy.splitText(text);
    }

    String[] executeWordSplitStrategy(String text) {
        return wordSplitStrategy.splitText(text);
    }

    /**
     * 根据文件路径获取合法对象
     *
     * @return
     */
    public abstract List<T> getValidObjectFromTextContent(String content);

}
